module RandomNumberGen(
    input clk,
    input rst_n,
    input start,
    input next,
    output reg [3:0] num,
    output reg done
);

    reg [3:0] cnt;

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            cnt <= 1;
            num <= 0;
            done <= 0;
        end else if (start) begin
            cnt <= 1;
            num <= 1;
            done <= 0;
        end else if (next && !done) begin
            if (cnt < 9) begin
                cnt <= cnt + 1;
                num <= cnt + 1;
            end else begin
                done <= 1;
            end
        end
    end

endmodule
